<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
*/

/**
 * Description of ViewHelper
 *
 * @author chaporgin_a
 */
class VA_Form_Decorator_ViewHelper extends VA_Form_Decorator {
  /**
   *
   * @var VA_Form_ViewHelper
   */
  private $helper = null;
  public function  __construct($options) {

  }
  public function render($content) {
    $this->generateHelper();
    return $content.$this->helper->wrap();
  }
  /**
   * generates ViewHelper by given FormElement
   */
  private function generateHelper() {
    switch (get_class($this->getElement())) {
      case 'VA_Form_FormElement_Textbox':
        $this->helper = new VA_Form_ViewHelper_XHTML_Textbox();
        break;
      case 'VA_Form_FormElement_Hidden':
        $this->helper = new VA_Form_ViewHelper_XHTML_Hidden();
        break;
      case 'VA_Form_FormElement_Submit':
        $this->helper = new VA_Form_ViewHelper_XHTML_Submit();
        break;
      case 'VA_Form_FormElement_Button':
        $this->helper = new VA_Form_ViewHelper_XHTML_Button();
        break;
      case 'VA_Form_FormElement_Textarea':
        $this->helper = new VA_Form_ViewHelper_XHTML_Textarea();
        break;
      case 'VA_Form_FormElement_Radio':
        $this->helper = new VA_Form_ViewHelper_XHTML_WithChoice();
        $this->helper->type = 'radio';
        break;
      case 'VA_Form_FormElement_Select':
        $this->helper = new VA_Form_ViewHelper_XHTML_Select();
        break;
      case 'VA_Form_FormElement_Checkbox':
        $this->helper = new VA_Form_ViewHelper_XHTML_WithChoice();
        $this->helper->type = 'checkbox';
        break;
      case 'VA_Form_FormElement_Captcha':
        $this->helper = new VA_Form_ViewHelper_XHTML_Captcha();
        break;
      case 'VA_Form_FormElement_File':
        $this->helper = new VA_Form_ViewHelper_XHTML_File();
        break;
      case 'VA_Form_FormElement_MultiFile':
        $this->helper = new VA_Form_ViewHelper_XHTML_MultiFile();
        break;
      case 'VA_Form_FormElement_Date':
        $this->helper = new VA_Form_ViewHelper_XHTML_Date();
        break;
      case 'VA_Form_FormElement_HtmlBlock':
        $this->helper = new VA_Form_ViewHelper_XHTML_HtmlBlock();
        break;
      }
    $this->helper->setElement($this->getElement());
  }
}

